<script setup>
import { ref } from 'vue';
  const emit = defineEmits(['add'])
  // 定义响应式数据
  const todowork = ref('');
  const addtodo = ()=>{
    if(todowork.value.trim() === ''){
      return ;
    }
    emit("add",todowork.value)
    todowork.value = "";
  }
</script>

<template>
  <!-- 输入框 -->
  <header class="header">
    <h1>记事本</h1>
    <input
      @keyup.enter="addtodo"
      v-model="todowork"
      placeholder="请输入任务"
      class="new-todo"
    />
    <button @click="addtodo" class="add">添加任务</button>
  </header>
</template>


<style>
</style>